<script>
export default {
  data() {
    return {
      dataList: [],
      visible: false
    }
  },
  methods: {
    opendialog() {
      // 父组件对子组件的引用
      this.$refs.add.dialogVisible = true;
    },
    deleterow(id,account) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http.get("api/admin?mark=deleteLog&id=" + id+"&account="+account).then((resp) => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
          this.$router.go();
        })

      }).catch(() => {
        // 用户点击了取消按钮，这里可以什么也不做，或者给用户一个反馈
        // 例如，可以使用 this.$message 来显示一个消息
        this.$message({
          type: 'info',
          message: '已取消删除操作'
        });
      });
    },
  },
  mounted() {
    this.$http.get("/api/admin?mark=getYearPeopleAccount").then((resp) => {
      if (resp.data.code == 200)
        this.dataList = resp.data.obj;
    })
  }

}
</script>

<template>
  <div>
    <el-card class="box-card">
      <span>投票后台</span>
      <el-table :data="dataList" height="850px" border style="width: 100%" :stripe="true">
        <el-table-column type="index" label="序号" width="80" align="center">
        </el-table-column>
        <el-table-column prop="account" label="被投票人学号" width="180" sortable="">
        </el-table-column>
        <el-table-column prop="name" label="被投票人姓名" width="140">
        </el-table-column>
        <el-table-column prop="id" label="投票人学号" width="180" sortable="">
        </el-table-column>
        <el-table-column prop="name2" label="投票人姓名" width="140">
        </el-table-column>
        <el-table-column prop="times" label="投票日期" width="200" sortable="">
        </el-table-column>
        <el-table-column label="操作" width="180" sortable="">
          <template slot-scope="scope">
            <el-button type="danger" icon="el-icon-delete" circle
                       @click="deleterow(scope.row.id,scope.row.account)"></el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<style>

</style>